<%--
  Created by IntelliJ IDEA.
  User: xianfei
  Date: 15-2-3
  Time: 下午3:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
    <title>订单管理</title>
    <script src="/static/bootstrap/js/bootstrap-paginator.js"></script>
    <script>
        $(function () {
            var status = $('[id^=status_]');
            for (var i = 0; i < status.length; i++) {
                if (status.eq(i).html() != "支付失败") {
                    $('#payOrder_' + i).attr("href", "javascript:void(0)");
                }
//                status.eq(i).html() == "已申请退款" ||
                if (status.eq(i).html() == "已退款") {
                    $("#refund_" + i).attr("href", "javascript:void(0)");
                }
            }

            $("#selectAll").click(function () {
                if ($(this).is(":checked")) {
                    $(":checkbox").prop("checked", "true");
                } else {
                    $(":checkbox").removeAttr("checked");
                }
            });

        });

        function deleteOrders() {
            var list = "";
            var guids = $("[id^=select_]");
            var count = 0;
            for (var i = 0; i < guids.length; i++) {
                if ($("#select_" + i).is(":checked")) {
                    count += 1;
                }
            }
            if (count <= 0) {
                alert("选择有误!");
                return false;
            }
            for (var i = 0; i < guids.length; i++) {
                if ($("#select_" + i).is(":checked")) {
                    list += $("#select_" + i).val() + ",";
                }
            }
            window.location.href = "/order/deleteMore/" + list;
        }

        function delorder(guid) {
            if (confirm("确定要删除该订单信息吗?")) {
                window.location.href = "/order/delete/" + guid;
            }
        }
    </script>
</head>
<body>
<div>
    <button type="button" class="btn btn-primary" onclick="deleteOrders()" title="删除选中的订单">批量删除</button>
    <table class="table table-striped">
        <thead>
        <th width="6%"><input type="checkbox" id="selectAll">全选</th>
        <th colspan="2" width="25%" scope="col">房屋信息</th>
        <th width="7%" scope="col">周次</th>
        <th width="10%" scope="col">份额单价（元）</th>
        <th width="7%" scope="col">数量</th>
        <th width="10%" scope="col">总金额（元）</th>
        <th width="15%" scope="col">订单时间</th>
        <th width="8%" scope="col">订单状态</th>
        <th width="26%" scope="col">订单操作</th>
        </thead>
        <tbody>
        <c:forEach items="${orderDTOs}" var="orderDTO" varStatus="status">
            <tr title="交易号:${orderDTO.orderInfoDTO.alipayTradeNo}">
                <input type="hidden" id="guid_${status.index}" value="${orderDTO.guid}">
                <td><input type="checkbox" id="select_${status.index}" value="${orderDTO.guid}"></td>
                <td><img style="width:30px;height:50px;" src="/public/image/${orderDTO.houseInfoDTO.imageGuids[0]}"
                         class="img11"></td>
                <td>${orderDTO.houseInfoDTO.name}<p>
                    面积${orderDTO.houseInfoDTO.buildingTypeArea}㎡丨${orderDTO.houseInfoDTO.buildingTypeName}</p></td>
                <td>${orderDTO.houseWeekDTO.name}</td>
                <td>￥<span class="price_item">${orderDTO.orderInfoDTO.singlePrice}</span></td>
                <td>${orderDTO.orderInfoDTO.num}</td>
                <td>￥<span class="price_item">${orderDTO.orderInfoDTO.totalPrice}</span></td>
                <td>${orderDTO.orderInfoDTO.time}</td>
                <td id="status_${status.index}">${orderDTO.orderInfoDTO.status}</td>
                <td><a href="/order/payOrder/${orderDTO.guid}" id="payOrder_${status.index}">支付</a>&nbsp;
                    <a href="javascript:void(0)" onclick="delorder('${orderDTO.guid}')" title="删除该订单信息">删除</a>&nbsp;
                    <a href="/order/toReFund/${orderDTO.guid}" id="refund_${status.index}" target="_blank"
                       title="申请退款">退款</a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
</body>
</html>